﻿using NMF.Languages.AnyText.ClassConstruction;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NMF.Languages.AnyText
{
    public class DateTimeTerminal : DataTypeTerminal<DateTimeType>
    {
        public DateTimeTerminal(string name) : base(name, new DateTimeType()) { }

        public override DataTypeTerminal<DateTimeType> CreateCustom()
        {
            return new DateTimeTerminal("CustomDateTime");
        }

        public override Irony.Parsing.BnfExpression CreateRule(AnyTextGrammar grammar)
        {
            return grammar.String.Rule;
        }

        public override object GetValue(Irony.Parsing.ParseTreeNode node)
        {
            var grammar = Grammar as AnyTextGrammar;
            return DateTime.Parse((string)grammar.String.GetValue(node));
        }
    }
}
